<h1>Pregled naročila</h1>
<?php $kosaricaHelper = $this->getHelper('Kosarica'); ?>
<?php $configHelper = $this->getHelper('Config'); ?>
<?php $strankeSession = new Zend_Session_Namespace('Store_Stranke'); ?>
<?php $stranka = new Application_Model_Stranka(); ?>
<?php $strankaMapper = new Application_Model_StrankaMapper(); ?>
<?php $strankaMapper->find($strankeSession->strankaId, $stranka); ?>
<div id="view-content">

	<div class="uporabnik">
		<h3>Podatki za dostavo in plačilo</h3>
		<ul>
			<li><b>Ime in priimek:</b> <?php echo $strankeSession->ime ?></li>
			<li><b>Email:</b> <?php echo $stranka->getEmail() ?></li>
			<li><b>Naslov:</b> <?php echo $stranka->getNaslov() ?></li>
			<li><b>Telefon:</b> <?php echo $stranka->getTelefon() ?></li>

		</ul>
	</div>

	<h3>Izdelki na naročilu</h3>
	<?php $kosarica = $kosaricaHelper->getKosarica(); ?>
	<?php if ($kosarica == null): ?>
		<p><?php echo "V košarici še ni izdelkov." ?></p>
		<?php return; ?>
	<?php endif; ?>
	<table id="kosarica-grid" class="table">

		<tr>
			<th>Ime izdelka:</th>  <th>Kolicina:</th> <th>Cena izdelka:</th><th>Skupna cena:</th>
		</tr>

                    <?php foreach ($kosarica as $kosara): ?>
                            <tr>

                                    <td><?php echo $kosara['izdelek']->getIme();  ?></td>
                                                   <td> <?php if ($kosara['kolicina']>$kosara['izdelek']->getZaloga()){
                       echo $kosara['izdelek']->getZaloga();
                    } else {

                         echo $kosara['kolicina'];
                    }
                     ?></td>
                                    <td><?php echo number_format($kosara['izdelek']->getCena(),2);?> <?php echo $configHelper->getCurrencySymbol() ?></td>
                   <td> <?php if ($kosara['kolicina']>$kosara['izdelek']->getZaloga()){
                        echo number_format($kosara['izdelek']->getCena() *$kosara['izdelek']->getZaloga(),2);echo $configHelper->getCurrencySymbol();
                    } else {

                         echo number_format($kosara['izdelek']->getCena() * $kosara['kolicina'],2);echo $configHelper->getCurrencySymbol();
                    }
                    ?></td>
                            </tr>
                    <?php endforeach; ?>
                    <tr>

		</tr>
		<?php $koncni=0 ?>
		<?php foreach ($kosarica as $kosara): ?>
       <tr> <?php if ($kosara['kolicina']>$kosara['izdelek']->getZaloga()){
                    
                    $koncni += $kosara['izdelek']->getCena() * $kosara['izdelek']->getZaloga();
                } else {
                    
                     $koncni += $kosara['izdelek']->getCena() * $kosara['kolicina'];
                }
          
                ?></tr>
        <?php endforeach; ?>
		<th>Končen znesek nakupa:</th> <th></th> <th></th>
		<td><?php echo number_format($koncni,2)?> <?php echo $configHelper->getCurrencySymbol() ?></td>
		<tr>

	</table>

	<button class="button btn-primary" onclick="javascript:window.location.href='<?php echo $this->url(array('action' => 'zakljucek', 'controller' => 'kosarica')); ?>'">Zakljucek nakupa</button>
</div>